WooCommerce AI Chatbot Workflow for Post-Sales Support

工作流概述

这是一个包含31个节点的复杂工作流,主要用于自动化处理各种任务。

工作流源代码

下载
{
  "id": "ODZpSQqCxkISEqv8",
  "meta": {
    "instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
    "templateCredsSetupCompleted": true
  },
  "name": "WooCommerce AI Chatbot Workflow for Post-Sales Support",
  "tags": [
    {
      "id": "NFwUyKypVupFwAM4",
      "name": "WooCommerce",
      "createdAt": "2024-12-13T15:34:20.174Z",
      "updatedAt": "2024-12-13T15:34:20.174Z"
    },
    {
      "id": "paTcf5QZDJsC2vKY",
      "name": "OpenAI",
      "createdAt": "2024-12-04T16:52:10.768Z",
      "updatedAt": "2024-12-04T16:52:10.768Z"
    }
  ],
  "nodes": [
    {
      "id": "25024dde-431b-4dad-b5ed-9be77cdf3db2",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -860,
        420
      ],
      "webhookId": "bb9b597a-25ed-43de-9ebb-14f166af789b",
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {
          "responseMode": "responseNode"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "96139b63-75aa-4d16-91b1-2fe0ca624137",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -520,
        720
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "f7901f97-50c5-4f56-bae3-21c575aa22cc",
      "name": "get_order",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        80,
        600
      ],
      "parameters": {
        "orderId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_ID', `Order Details Retrieval Process:
1. Request Order Number
   - Explicitly ask customer for the complete order number

2. Identity Verification
   - Ask for the email address associated with the order
   - Strictly verify that the provided email matches the order record
   - If email does NOT match the order:
     * Immediately halt the process
     * Inform customer that the email is incorrect
     * Do NOT provide the correct email
     * Prevent access to order details

3. Verification Criteria
   - Exact match of email to order record is mandatory
   - No exceptions or workarounds
   - Customer must provide the precise, correct email`, 'string') }}",
        "resource": "order",
        "operation": "get"
      },
      "credentials": {
        "wooCommerceApi": {
          "id": "nCgFKMfBO95v38Mp",
          "name": "WooCommerce (magnanigioielli.com)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b448fb28-1bba-4743-923f-4198bdea0165",
      "name": "get_orders",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        180,
        600
      ],
      "parameters": {
        "options": {
          "search": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search', ``, 'string') }}"
        },
        "resource": "order",
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "wooCommerceApi": {
          "id": "nCgFKMfBO95v38Mp",
          "name": "WooCommerce (magnanigioielli.com)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4b386cd5-1f42-45b9-bfa6-e8caf50d49b3",
      "name": "get_user",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        280,
        600
      ],
      "parameters": {
        "filters": {
          "email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}"
        },
        "resource": "customer",
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "wooCommerceApi": {
          "id": "nCgFKMfBO95v38Mp",
          "name": "WooCommerce (magnanigioielli.com)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2235e0c5-ad5e-42d3-a6da-19513dcba181",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        -400,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e3b8fd50-2f47-4866-acc7-88e819b9d2ce",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -980,
        -500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7ac0573f-fcc0-426e-b412-1f4a1e38b9ee",
      "name": "Create collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -680,
        -640
      ],
      "parameters": {
        "url": "https://QDRANTURL/collections/COLLECTION",
        "method": "POST",
        "options": {},
        "jsonBody": "{
  \"filter\": {}
}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "qhny6r5ql9wwotpn",
          "name": "Qdrant API (Hetzner)"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "15de11a6-27eb-4431-9105-a7f07f103d44",
      "name": "Refresh collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -680,
        -380
      ],
      "parameters": {
        "url": "https://QDRANTURL/collections/COLLECTION/points/delete",
        "method": "POST",
        "options": {},
        "jsonBody": "{
  \"filter\": {}
}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "qhny6r5ql9wwotpn",
          "name": "Qdrant API (Hetzner)"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "aab947f3-3e7f-4068-8183-a6003754dc16",
      "name": "Get folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -460,
        -380
      ],
      "parameters": {
        "filter": {
          "driveId": {
            "__rl": true,
            "mode": "list",
            "value": "My Drive",
            "cachedResultUrl": "https://drive.google.com/drive/my-drive",
            "cachedResultName": "My Drive"
          },
          "folderId": {
            "__rl": true,
            "mode": "id",
            "value": "=test-whatsapp"
          }
        },
        "options": {},
        "resource": "fileFolder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "HEy5EuZkgPZVEa9w",
          "name": "Google Drive account (n3w.it)"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "091b9080-eae0-433a-80e6-d1c553b4912b",
      "name": "Download Files",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -240,
        -380
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "text/plain"
            }
          }
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "HEy5EuZkgPZVEa9w",
          "name": "Google Drive account (n3w.it)"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "400fcdde-ef42-49bf-807d-e2ed029aae1f",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        160,
        -180
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "b3f39ac8-ebbc-42c5-8368-2fedd8d133f3",
      "name": "Token Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterTokenSplitter",
      "position": [
        140,
        0
      ],
      "parameters": {
        "chunkSize": 300,
        "chunkOverlap": 30
      },
      "typeVersion": 1
    },
    {
      "id": "a17ed192-cd39-456d-b35a-ee7d8532fb7c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -700
      ],
      "parameters": {
        "color": 6,
        "width": 880,
        "height": 220,
        "content": "# STEP 1

## Create Qdrant Collection
Change:
- QDRANTURL
- COLLECTION"
      },
      "typeVersion": 1
    },
    {
      "id": "ce12df1d-357a-4f8f-91cf-f92c0aa6bcd7",
      "name": "Qdrant Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        0,
        -380
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "qdrantCollection": {
          "__rl": true,
          "mode": "id",
          "value": "=COLLECTION"
        }
      },
      "credentials": {
        "qdrantApi": {
          "id": "iyQ6MQiVaF3VMBmt",
          "name": "QdrantApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e440121d-6aa8-4cc7-920c-d28d93717d99",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        0,
        -160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "CDX6QM4gLYanh0P4",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "c6f89301-3ae0-4068-8279-de149859f6a5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -440
      ],
      "parameters": {
        "color": 4,
        "width": 620,
        "height": 400,
        "content": "# STEP 2












## Documents vectorization with Qdrant and Google Drive
Change:
- QDRANTURL
- COLLECTION"
      },
      "typeVersion": 1
    },
    {
      "id": "7ae502f5-bf12-49bd-afd0-d8ad050c1d8b",
      "name": "Qdrant Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        -140,
        960
      ],
      "parameters": {
        "options": {},
        "qdrantCollection": {
          "__rl": true,
          "mode": "id",
          "value": "=COLLECTION"
        }
      },
      "credentials": {
        "qdrantApi": {
          "id": "iyQ6MQiVaF3VMBmt",
          "name": "QdrantApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b3bc247f-7fcb-4c17-8995-ec4ba26b65ee",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -160,
        1140
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "CDX6QM4gLYanh0P4",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "7c110a8b-5e66-4824-ac9f-a42fabbe3929",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        160,
        960
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "CDX6QM4gLYanh0P4",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b9a62833-a124-439b-b6ca-eb6061afa74d",
      "name": "ToS",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        -40,
        780
      ],
      "parameters": {
        "name": "company",
        "description": "Rispondi alle domande relative ai termini e condizioni e spedizioni"
      },
      "typeVersion": 1
    },
    {
      "id": "667e8756-78a6-4cd1-bf24-00af8188fe50",
      "name": "get_tracking",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -240,
        600
      ],
      "parameters": {
        "name": "get_tracking",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "AcPE4PXeFOiOW48H",
          "cachedResultName": "WooCommerce Get Tracking Number"
        },
        "description": "Get tracking number for a specific order by providing the order number. The tool retrieves the unique tracking code that allows customers to monitor their shipment's current status and location.",
        "workflowInputs": {
          "value": {
            "order_number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('order_number', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "order_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "order_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "order_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "305ea876-80b9-45c4-b548-6d1df093bd94",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        560,
        480
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{
  \"order_number\": \"order number\"
}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4f7547c1-1d21-45f6-a409-09e55c4b9477",
      "name": "Post-Sales Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -540,
        420
      ],
      "parameters": {
        "options": {
          "systemMessage": "=## Role and Primary Objective
You are a customer support AI agent for an online clothing store, specializing in post-sales assistance. Your primary goals are to:
- Help customers track their orders
- Provide information about past and current orders
- Offer clear and concise support

## Communication Guidelines
1. Always be professional, helpful, and precise
2. Use available tools to retrieve accurate information
3. Verify customer identity before sharing order details
4. Protect customer privacy and data confidentiality

## Tool Usage Instructions

### Order Information Retrieval
- Use `get_order` to fetch details for a single order
  - REQUIRED: Complete user information including request, email, and order number
- Use `get_orders` to retrieve multiple orders for a single customer
- Use `get_user` to obtain customer profile information

### Tracking and Support
- Use `get_tracking` to obtain tracking information for an order using the order number
- If a customer cannot find what they need, use `human*assistance`
  - Synthesize the request clearly
  - Include associated user email
  - Provide concise, relevant details

### General Information
- Use `ToS` tool to answer questions about:
  - Terms and Conditions
  - Shipping information
  - General store policies

## Critical Verification Rules
- ALWAYS verify that the email provided matches the order number
- If the email does not match the order:
  - DO NOT provide the correct email
  - Inform the customer that the email address is incorrect
  - Request the correct email associated with the order

## Prohibited Actions
- Never disclose sensitive customer information
- Do not share full order details without proper verification
- Avoid providing speculative or unconfirmed information

## Communication Style
- Be direct and helpful
- Use clear, professional language
- Focus on solving the customer's specific query
- Provide step-by-step guidance when necessary

## Escalation Protocol
- If unable to resolve the customer's issue using available tools
- Use `human_assistance` to escalate complex or unresolvable queries
- Ensure clear, concise problem description

Today is {{$now}}"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "a5b49dbf-f041-43ec-b621-a89f65675705",
      "name": "human_assistence",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        -80,
        600
      ],
      "webhookId": "1f9cad22-45e3-4c6b-bec8-f421060d14d9",
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "CHAT_ID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "rQ5q95W7uKesMDx4",
          "name": "Telegram account Fastewb"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "46110bcd-dae7-4c33-8936-cc4867c9abde",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        240
      ],
      "parameters": {
        "width": 1220,
        "height": 140,
        "content": "# STEP 3

- Add your Telegram CHAT_ID in the \"human_assistance\" tool"
      },
      "typeVersion": 1
    },
    {
      "id": "9c45d20d-f4d3-4bde-9e3e-749c64a123bb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 580,
        "height": 200,
        "content": "# STEP 4

The tracking code request is made through the most popular WooCommerce tracking plugin: \"YITH WooCommerce Order & Shipment Tracking\". The free version can be [downloaded here](https://wordpress.org/plugins/yith-woocommerce-order-tracking/)
- Create a new workflow and change URL in the node \"Http Request\" with your WooCommerce shop url"
      },
      "typeVersion": 1
    },
    {
      "id": "f16ee312-8434-4958-b111-d80384ae869c",
      "name": "Get tracking",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        780,
        480
      ],
      "parameters": {
        "url": "=https://URL/wp-json/wc/v3/orders/{{ $json.order_number }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "id": "nIitKwSJa9EpgG8K",
          "name": "WP (magnanigioielli.com)"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e5de4ad6-3469-4720-828e-618db5c4f3ae",
      "name": "Set tracking code",
      "type": "n8n-nodes-base.set",
      "position": [
        1020,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "19b33abc-5191-4449-b682-4466f1975ff2",
              "name": "tracking_code",
              "type": "string",
              "value": "={{ $json[\"meta_data\"].find(item => item.key === \"ywot_tracking_code\").value }}"
            },
            {
              "id": "2e18b337-e3e8-4669-a902-ecc2ba027a1a",
              "name": "carrier_url",
              "type": "string",
              "value": "={{ $json[\"meta_data\"].find(item => item.key === \"ywot_carrier_url\").value }}"
            },
            {
              "id": "ae834f65-67b2-4e95-9a49-5172e36fc5b9",
              "name": "pick_up",
              "type": "string",
              "value": "={{ $json[\"meta_data\"].find(item => item.key === \"ywot_pick_up_date\").value }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b889e33b-5243-4b5b-80ef-023df779e673",
      "name": "GPT 4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -700,
        720
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "CDX6QM4gLYanh0P4",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c9863b08-f6aa-4502-85a4-7782a090d532",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        -1040
      ],
      "parameters": {
        "color": 3,
        "width": 1400,
        "height": 240,
        "content": "# WooCommerce AI Chatbot Workflow for Post-Sales Support

This WooCommerce-integrated chatbot is designed to transform post-sales customer support by combining automation and artificial intelligence to deliver fast, secure, and personalized assistance. By connecting directly to the WooCommerce database, the chatbot retrieves real-time order information—including shipping details and tracking numbers—after verifying the customer's identity through a strict email-based authentication system. This ensures maximum data security, preventing leaks of sensitive information.  

Beyond order management, the chatbot answers frequently asked questions about return policies, delivery times, and terms of service using a vector database that provides accurate, context-aware responses. If a request is too complex, the system seamlessly escalates it to a human operator via Telegram, guaranteeing no customer query goes unresolved. 
"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bace4bf0-d6b4-46f8-81d1-26dbc1120d85",
  "connections": {
    "ToS": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_user": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_order": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get folder": {
      "main": [
        [
          {
            "node": "Download Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_orders": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GPT 4o-mini": {
      "ai_languageModel": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get tracking": {
      "main": [
        [
          {
            "node": "Set tracking code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_tracking": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Download Files": {
      "main": [
        [
          {
            "node": "Qdrant Vector Store1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Token Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Post-Sales Agent": {
      "main": [
        []
      ]
    },
    "human_assistence": {
      "ai_tool": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "ToS",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Refresh collection": {
      "main": [
        [
          {
            "node": "Get folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Qdrant Vector Store1",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "ToS",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Post-Sales Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get tracking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Create collection",
            "type": "main",
            "index": 0
          },
          {
            "node": "Refresh collection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

  • 自动检测新邮件
  • AI智能内容分析
  • 自定义分类规则
  • 批量处理能力
  • 详细的处理日志

技术分析

节点类型及作用

  • @N8N/N8N Nodes Langchain.Chattrigger
  • @N8N/N8N Nodes Langchain.Memorybufferwindow
  • Woocommercetool
  • @N8N/N8N Nodes Langchain.Toolcalculator
  • Manualtrigger

复杂度评估

配置难度:
★★★★☆
维护难度:
★★☆☆☆
扩展性:
★★★★☆

实施指南

前置条件

  • 有效的Gmail账户
  • n8n平台访问权限
  • Google API凭证
  • AI分类服务订阅

配置步骤

  1. 在n8n中导入工作流JSON文件
  2. 配置Gmail节点的认证信息
  3. 设置AI分类器的API密钥
  4. 自定义分类规则和标签映射
  5. 测试工作流执行
  6. 配置定时触发器(可选)

关键参数

参数名称 默认值 说明
maxEmails 50 单次处理的最大邮件数量
confidenceThreshold 0.8 分类置信度阈值
autoLabel true 是否自动添加标签

最佳实践

优化建议

  • 定期更新AI分类模型以提高准确性
  • 根据邮件量调整处理批次大小
  • 设置合理的分类置信度阈值
  • 定期清理过期的分类规则

安全注意事项

  • 妥善保管API密钥和认证信息
  • 限制工作流的访问权限
  • 定期审查处理日志
  • 启用双因素认证保护Gmail账户

性能优化

  • 使用增量处理减少重复工作
  • 缓存频繁访问的数据
  • 并行处理多个邮件分类任务
  • 监控系统资源使用情况

故障排除

常见问题

邮件未被正确分类

检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。

Gmail认证失败

确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。

调试技巧

  • 启用详细日志记录查看每个步骤的执行情况
  • 使用测试邮件验证分类逻辑
  • 检查网络连接和API服务状态
  • 逐步执行工作流定位问题节点

错误处理

工作流包含以下错误处理机制:

  • 网络超时自动重试(最多3次)
  • API错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作